using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AXBC = Microsoft.Dynamics.BusinessConnectorNet;
using AXMD = Microsoft.Dynamics.Framework.Metadata.Ax;
using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;

namespace DynamicsAXPS
{
    [System.Management.Automation.Cmdlet("Set", "AXNodeProperty")]
    public class Set_AXNodeProperty : System.Management.Automation.PSCmdlet
    {
        [System.Management.Automation.Parameter(Position = 0, Mandatory = true)]
        public string Path;

        [System.Management.Automation.Parameter(Position = 1, Mandatory = true)]
        public string Name;

        [System.Management.Automation.Parameter(Position = 2, Mandatory = true)]
        public object Value;

        protected override void ProcessRecord()
        {
            var ax_session = Microsoft.Dynamics.Framework.Portal.SessionHelper.Instance.GetSession();
            var node = Proxy.TreeNode.findNode(ax_session.AxaptaAdapter, Path);
            node.AOTsetProperty(this.Name, this.Value);
            node.AOTsave();
        }
    }
}
